<%--
  Created by IntelliJ IDEA.
  User: 27933
  Date: 2021/10/15
  Time: 17:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="/themes/gray/easyui.css">
    <link rel="stylesheet" type="text/css" href="/themes/icon.css">
    <script src="/jquery.min.js"></script>
    <script src="/jquery.easyui.min.js"></script>

    <script>
        $(function (){
            $("#loginForm").submit(function (e) {
                e.preventDefault();
                $.post(
                    "/loginController",
                    $(this).serialize(),
                    function (data) {
                        if (data.result == true){
                            alert("登录成功");
                            location.href = "index.jsp"
                        }else {
                            alert("登录失败");
                            location.href = "login.jsp"
                        }
                    },"json"
                );
            });
        //
        // });
        // $(function () {
        //     $("#loginForm").submit(function (e) {
        //         e.preventDefault();
        //         alert($("#loginForm").serialize());
        //     });
        // });


        // $(function () {
        //     $("#usersname").blur(function () {
        //         alert("zzzzz")
        //         var username = this.value;
        //         $.getJSON("/loginServlet","action=ajaxExistsName&username=",function (data) {
        //             if(data.existsName){
        //                 $("#sa").innerText("用户名已存在！")
        //             }else {
        //                 $("#sa").innerText("用户名可用！")
        //             }
        //
        //         })
        //     });
        // });

        // $(function () {
        //     $("#usersname").submit(function (e) {
        //         e.preventDefault();
        //         $.post("/loginController",
        //             $(this).serialize(), function (data) {
        //                 location.hrea = "index.jsp";
        //             }, "json");
        //
        //     });

        })

    </script>
</head>
<body>
<form action="" id="loginForm">
    <input type="text" placeholder="请输入姓名" name="name" id="usersname"><br>
    <input type="password" placeholder="请输入年龄" name="password"><br>
<%--    复选--%>
<%--    <input type="checkbox" name="check" value="check1"/>check1--%>
<%--    <input type="checkbox" name="check" value="check2" checked/>check2 </br>--%>
<%--    单选--%>
<%--    <input type="radio" name="radio" value="radio1" checked/>radio1--%>
<%--    <input type="radio" name="radio" value="radio2"/>radio2</br>--%>
    <input type="submit" value="提交">
</form>

</body>
</html>
